package fr.umlv.projet.android.subject;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import fr.umlv.projet.android.andex.R;
import fr.umlv.projet.android.getExam.GetExamService;

public class ListSubjectActivity extends ListActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		String[] examArray = getIntent().getStringArrayExtra("exams");
		
		
		ArrayList<String> listExam = new ArrayList<String>();
		for (String l : examArray) {
			listExam.add(l);
		}
		setListAdapter(new ArrayAdapter<String>(this, R.layout.list_subject, listExam));
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		Intent intent = new Intent(this, GetExamService.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		intent.putExtra("exam", ((TextView) v).getText());
		startService(intent);
	}

}
